//
//  searchView.m
//  商城
//
//  Created by runone02 on 2018/9/17.
//  Copyright © 2018年 liqiyun. All rights reserved.
//

#import "searchView.h"

@interface searchView ()<UISearchBarDelegate>

@end
@implementation searchView


- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    self.switchViewButton = [[UIButton alloc] init];
    [self.switchViewButton setImage:IMAGE(@"flzq_nav_jiugongge") forState:UIControlStateNormal];
    [self.switchViewButton setImage:IMAGE(@"flzq_nav_list") forState:UIControlStateSelected];

    [self addSubview:self.switchViewButton];
    [self.switchViewButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self);
        make.right.mas_equalTo(-10);
        make.width.height.mas_equalTo(30);
    }];


    _searchButton = [UIButton buttonWithType:UIButtonTypeCustom];

    _searchButton.titleLabel.font = TITLE_FONT(26);
    [_searchButton setTitle:@"搜索商品/店铺" forState:UIControlStateNormal];
    [_searchButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    [_searchButton.layer setMasksToBounds:YES];
    [_searchButton.layer setCornerRadius:0];

    [_searchButton.layer setBorderWidth:1.0];
    _searchButton.layer.borderColor = [UIColor lightGrayColor].CGColor;
    

    
    [self addSubview:self.searchButton];
    
    [self.searchButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self);
        make.left.mas_equalTo(self).with.offset(10);
        make.right.mas_equalTo(self.switchViewButton.mas_left).with.offset(-10);
        make.height.mas_equalTo(28);
    }];

}

- (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size {
    CGRect rect = CGRectMake(0, 0, size.width, size.height);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    
    CGContextSetFillColorWithColor(context, [color CGColor]);
    CGContextFillRect(context, rect);
    
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}

@end
